
/* --------------------------------------------- MPI -------------------------------------- */
/* ---------------------------------- check fields have been received and sent ------------ */
#ifdef MPI


 {int field, coord, side; 
 for (field = 0; field < N_FIELDS_MPI; field++){
     for (coord = 0; coord < DIM; coord++){ /* warning we do not loop along the z direction */
     for (side = 0; side < 2; side++){

		   tag =  2*DIM*N_GRIDS*field + 2*DIM*grid
		       + 2*coord
		       + side;
#ifdef DEBUG_MPI
printf("Before wait recv: field = %d, grid = %d, coord = %d, side = %d \n",field, grid, coord, side);fflush(stdout);
#endif
		   MPI_Wait(&reqr[tag], &status);
#ifdef DEBUG_MPI
printf("After wait recv: field = %d, grid = %d, coord = %d, side = %d \n",field, grid, coord, side);fflush(stdout);
#endif
/*        if((*grid_ptr).gcs_send[grid][coord][side].g>=0){ */
	 grid_to=(*grid_ptr).gcs_send[grid][coord][side].g;
	 tag=2*DIM*N_GRIDS*field + 2*DIM*grid_to 
	     + 2*(*grid_ptr).gcs_send[grid][coord][side].c+(*grid_ptr).gcs_send[grid][coord][side].s;
#ifdef DEBUG_MPI
printf("Before wait send: field = %d, grid = %d, coord = %d, side = %d, tag = %d \n",field, grid, coord, side, tag);fflush(stdout);
#endif
		   MPI_Wait(&reqs[tag], &status);
#ifdef DEBUG_MPI
printf("After wait send: field = %d, grid = %d, coord = %d, side = %d \n",field, grid, coord, side);fflush(stdout);
#endif
/* 	       } */
     }}}}

#ifdef DEBUG_MPI
 printf("After wait in n%d \n",grid);fflush(stdout);
/*  {register int field, grid_ind1, grid_ind2;  */
/*  FLOAT SUM = 0.0; */

/*  for (field = 0; field < N_FIELDS; field++){ */
/*      for (grid_ind2 = ni_2; grid_ind2 < nf_2; ++grid_ind2){ */
/* SUM =  SUM  + sfield_send.s_1_0_u[field][grid_ind2] - sfield_recv.s_1_1_u[field][grid_ind2] ; */
/* SUM = SUM + sfield_send.s_1_1_u[field][grid_ind2] - sfield_recv.s_1_0_u[field][grid_ind2] ; */
/*      } */
/*      printf("n%d    SUM[%d] = %f \n", grid, field, SUM/(FLOAT)(nf_2-ni_2));  */
/*      SUM = 0.0; */
/*  } */
/*  } */
/* fflush(stdout); */

#endif
#endif
